import Vue from 'vue'
import VueRouter from 'vue-router'
import Test from '@/views/Test.vue'
import PrivateMune from '@/views/PrivateMune.vue'
import EmpVue from '@/views/EmpVue.vue'
import MyLogin from '@/views/login/MyLogin.vue'
import { component } from 'vue/types/umd'

Vue.use(VueRouter)

const routes = [
  
  {
    path: '/test',
    name: 'Test',
    component: Test
  },
  {
    path: '/menu',
    name: 'menu',
    component: PrivateMune
  },
  {
    path: '/empvue',
    name: 'empvue',
    component: EmpVue
  },
  {
    path: '/login',
    name: 'login',
    component: ()=>import('../views/login/MyLogin.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/login/MyRegister.vue')
  },
  {
    path: '/layout',
    name: 'layout',
    component: () => import('../views/layout/MainLayout.vue'),
    redirect: '/student/information',
    children: [
      // {
      //   path:'/home',
      //   component: ()=>import('../views/Home.vue')
      // },
      {
        path:'/student/information',
        component: ()=>import('../views/student/Information.vue')
      },
      {
        path:'/student/books',
        component: ()=>import('../views/student/BookForStudent.vue')
      },
      // {
      //   path:'/teacher/information',
      //   component: ()=>import('../views/teacher/TeacherInformation.vue')
      // },
    ]
  }

]

const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  if (to.path === from.path) {
    next(false); // 阻止重复导航
  } else {
    next();
  }
})
export default router
